package cn.gzmli.dtt.common.entity;

/**
 * 分页信息pojo类
 *
 * @author wonderful
 */
public class PageInfo {


    private Integer curPage = 0;

    private Integer pageSize = 0;

    private long totalPages = 0;

    private long totalRows = 0;

    private String orderData;

    public Integer getCurPage() {
        return curPage;
    }

    public void setCurPage(Integer curPage) {
        this.curPage = (curPage == null ? 0 : curPage);
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = (pageSize == null ? 0 : pageSize);
    }

    public float getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = (totalPages == null ? 0 : totalPages);
    }

    public float getTotalRows() {
        return totalRows;
    }

    public String getOrderData() {
        if (this.orderData != null) {
            orderData = orderData.replace('+',' ');
        }
        return orderData;
    }

    public void setOrderData(String orderData) {
        this.orderData = orderData;
    }

    public void setTotalRows(long totalRows) {

        this.totalRows = totalRows;
    }

    //生成总页数
    public void createTotalPages() {

        if (totalRows >= pageSize && totalRows % pageSize == 0) {
            this.totalPages = totalRows / pageSize;
        } else if (totalRows >= pageSize && totalRows % pageSize != 0) {
            this.totalPages = totalRows / pageSize + 1;
        } else if (totalRows > 0 && totalRows < pageSize) {
            this.totalPages = 1;
        }
    }

    //起始行
    public Integer getStartRow() {
        return this.curPage > 0 ? (this.curPage - 1) * this.pageSize : 0;
    }

    //每页条数
    public Integer getEndRow() {
        return this.curPage * this.pageSize;
    }
}
